﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using AutoMapper;

using Revis.VClinicNet.Core.Domain;
using Revis.VClinicNet.Core.Domain.Credentials;

namespace Revis.VClinicNet.App.Internal.Dto.Mappers
{
    public class PatientUserDtoMapper : IDtoMapper
    {
        public static Func<Patient, string> Name = (p) => {
            return String.Format("{0} {1}", p.Personal.FirstName, p.Personal.Surname);
        };

        public void Map()
        {
            Mapper.CreateMap<PatientUser, PatientUserActiveDto>()
                .ForMember(p => p.Name, mo => mo.MapFrom(u => Name(u.Related)))
                .ForMember(p => p.Login, mo => mo.MapFrom(u => u.Related.Personal.Pesel))
                .ForMember(p => p.Password, mo => mo.Ignore());

            Mapper.CreateMap<PatientUser, PatientUserInfoDto>()
                .ForMember(p => p.Name, mo => mo.MapFrom(u => Name(u.Related)))
                .ForMember(p => p.Login, mo => mo.MapFrom(u => u.Related.Personal.Pesel))
                .ForMember(p => p.PatientId, mo => mo.MapFrom(u => u.Related.Id));
        }
    }
}
